const CompressionWebpackPlugin = require('compression-webpack-plugin');
const path = require("path");
function resolve(dir) {
  return path.join(__dirname, dir);
}
module.exports = {
  publicPath:'./',
  productionSourceMap: false,
  transpileDependencies: ['element-ui', 'ele-admin', 'vue-i18n'],
  devServer: {
    proxy: {
      '^/': {
        target: process.env.VUE_APP_API_BASE_URL,
        // 允许跨域
        changOrigin: true,
        ws: false,
      },
      // Fixed cross.
      '/': {
        target: process.env.VUE_APP_API_BASE_URL,
        changOrigin: true,
        pathRewrite: {
          '^/': '',
        }
      }
    }
  },
  chainWebpack: (config) => {
    config.resolve.alias
      .set("@", resolve("src"))
      .set("@assets", resolve("src/assets"))
      .set("@components", resolve("src/components"))
      .set("@base", resolve("baseConfig"))
      .set("@public", resolve("public"));
    config.plugins.delete('prefetch');
    if (process.env.NODE_ENV !== 'development') {
      // 对超过10kb的文件gzip压缩
      config.plugin('compressionPlugin').use(new CompressionWebpackPlugin({
        test: /\.(js|css|html)$/,
        threshold: 10240
      }));
    }
  },
  css: {
    loaderOptions: {
      sass: {
        sassOptions: {
          outputStyle: 'expanded'
        }
      }
    }
  },

}
